package database.helpers;

import android.annotation.SuppressLint;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

@SuppressLint("ParserError")
public class databas_helper extends SQLiteOpenHelper  {
	
	private static final String DATABASE_NAME = "Ufollo_database.db";
	private static final int DATABASE_VERSION = 1;

//	private static final String TAG = "SQLiteOpenHelper"; 
	
	
	public databas_helper(Context context) {
		   
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
				
	}
	
	
	private static final String CREATE_CaringFriend = "create table "
			+ CaringFriend_Table.CARINGFRIEND_TABLE + "( " + CaringFriend_Table.CARINGFRIEND_ID + " integer primary key autoincrement, " +  CaringFriend_Table.CARINGFRIEND_NAME + " text not null, " + CaringFriend_Table.CARINGFRIEND_PENDINGQN
			+ " text not null, " + CaringFriend_Table.CARINGFRIEND_CELLNUMBER + " text not null, " + CaringFriend_Table.CARINGFRIEND_EMAIL + " text not null  )";
	
	private static final String CREATE_FAQS = "create table "
			+ FAQS_Table.FAQS_TABLE + "( " + FAQS_Table.FAQS_ID + " integer primary key autoincrement, " + FAQS_Table.FAQS_QSTN 	+ " text not null, " + FAQS_Table.FAQS_ANS + " text not null )";
	
	private static final String CREATE_FEEDBACK = "create table "
			+ Feedback_Table.FEEDBACK_TABLE + "( " + Feedback_Table.FEEDBACK_ID + " integer primary key autoincrement, " + Feedback_Table.FEEDBACK_CARINGFRIEND 	+ " text not null, " + Feedback_Table.FEEDBACK_MSG + " text not null )";
	
	private static final String CREATE_Lesson= "create table "
			+ Lesson_Table.LESSON_TABLE + "( " + Lesson_Table.LESSON_ID + " integer primary key autoincrement, " + Lesson_Table.LESSON_NAME 	+ " text not null, " + Lesson_Table.LESSON_MSG+ " text not null, " + Lesson_Table.LESSON_TYPE
			+ " text not null, " + Lesson_Table.LESSON_QSTN+ " text not null, " + Lesson_Table.LESSON_ANS+ " text not null," + Lesson_Table.LESSON_ISCOMPLETE+ " text not null )";
	
	private static final String CREATE_Seeker = "create table "
			+ Seeker_Table.SEEKER_TABLE + "( " + Seeker_Table.SEEKER_ID + " integer primary key autoincrement, " + Seeker_Table.SEEKER_NAME 	+ " text not null, " + Seeker_Table.SEEKER_USERNAME + " text not null , " + Seeker_Table.SEEKER_PIN + " text not null , " + 
			Seeker_Table.SEEKER_ISCHRISTIAN + " text not null, " + Seeker_Table.SEEKER_EMAIL + " text not null , " + Seeker_Table.SEEKER_HAVECF + " text not null   )";
	
	private static final String CREATE_Testimony = "create table " 
			+ Testimony_Table.TESTIMONY_TABLE+ "( " + Testimony_Table.TESTIMONY_ID + " integer primary key autoincrement, " + Testimony_Table.TESTIMONY_TYPE	+ " text not null, " + Testimony_Table.TESTIMONY_USERNAME + " text not null, " + Testimony_Table.TESTIMONY_URL
			+ " text not null, " + Testimony_Table.TESTIMONY_CONTENT + " text not null )";
	
	private static final String CREATE_VOTD = "create table "
			+ VOTD_Table.VOTD_TABLE + "( " + VOTD_Table.VOTD_ID + " integer primary key autoincrement, " + VOTD_Table.VOTD_Day 	+ " text not null, " + VOTD_Table.VOTD_CONTENT + " text not null, " + VOTD_Table.VOTD_REFSCRIPT + " text not null, "+ VOTD_Table.VOTD_wasREAD
			+ " text not null )";
	
	@Override
	public void onCreate(SQLiteDatabase database) {
	
		database.execSQL(CREATE_CaringFriend);		
		database.execSQL(CREATE_FAQS);	
		database.execSQL(CREATE_FEEDBACK);	
		database.execSQL(CREATE_Lesson);	
		database.execSQL(CREATE_Seeker);		
		database.execSQL(CREATE_Testimony);
		database.execSQL(CREATE_VOTD);
		
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		
		Log.w(databas_helper.class.getName(),
				"Upgrading database from version " + oldVersion + " to "
						+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + CaringFriend_Table.CARINGFRIEND_TABLE + FAQS_Table.FAQS_TABLE + Feedback_Table.FEEDBACK_TABLE + Lesson_Table.LESSON_TABLE+Seeker_Table.SEEKER_TABLE +Testimony_Table.TESTIMONY_TABLE+ VOTD_Table.VOTD_TABLE);
		onCreate(db);
	}

	

}
